<?php //use_javascript("date.js") ?>

<div id="contentTop">
<div id="lookforTitle"><h2>さがす</h2></div>


<!-- 1.とマップが入るところ。 -->
<div id="koumoku">
<table>
<tr>
<td>
<h2><font color="#fff">1.　エリアを見る:</font><?php //print_r($maybetype);?></h2>
</td>
<td>
<?php echo form_tag("@find", "method=post multipart=true")?>
<?php echo input_tag("search_place", "", array("size => 50")); ?>
<?php echo input_hidden_tag("hidmaybetype", $hidmaybetype); ?>
<?php echo input_hidden_tag("hidmaybecolor", $hidmaybecolor); ?>
<?php //echo input_hidden_tag("found", $found); ?>
<?php echo submit_tag("GO")?>
</form>
</td>
<td><h3><font color="#fff"><?php echo ($search_place)?"　　エリア：　".htmlspecialchars($search_place):"";?></font></h3></td>
</tr>
</table>
</div>
<br>

<div id="map">

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">

    google.maps.event.addDomListener(window, 'load', function()
            {
            var geocoder = new google.maps.Geocoder();
            geocoder.geocode({
    	      'address': '<?php echo ($search_place)?$search_place:"東京都新宿区";?>'
            }, function(result, status) {
    	      if (status == google.maps.GeocoderStatus.OK) {
              var latlng = result[0].geometry.location;

//                var lng = 139.81925904750824;
//                var lat = 35.6832894073129;

                var mapOptions = {
                    zoom: 12,
                    center: latlng,
                    //center: new google.maps.LatLng(lat, lng),
                    mapTypeId: google.maps.MapTypeId.ROADMAP,
                    scaleControl: true
                };


                var mapObj = new google.maps.Map(document.getElementById('map'), mapOptions);


                // 検索候補
                <?php //if(!$found):?>

                <?php //if($maybetype):?>
                <?php //foreach($maybetype as $v):?>
                //var maybes = [
                  //['<?php //echo $v->getID();?>//', <?php //echo $v->getLati();?>//, <?php //echo $v->getLongi();?>//],
                  // ex.['新宿', 35.688964547432306, 139.69959765672684]
                //];

                // マーカーを作成
                ///jQuery.each(maybes, function()
                //{
                    //var latlng = new google.maps.LatLng(this[1], this[2]);
                    //var infoWindow = new google.maps.InfoWindow({
              	    //    content: ' が見つかりました！<br>特徴: <?php //echo $v->getType(), ",", $v->getColor(), ",", "(",$v->getSonota(), ")" ?>//<br><?php //echo $v->getHinichi()?>//に見つかりました。<br><strong><?php //echo $v->getKeptin()?>//</strong>に届いてるかも！',
                    //});
                    //var marker = new google.maps.Marker({
                    //    position: latlng,
                    //    map: mapObj,
                    //    title: this[0]
                    //});
                    //google.maps.event.addListener(marker, 'click', function() {
                	 //   infoWindow.open(map, marker);

                   // });
                 //});
                <?php //endforeach;?>
                <?php //endif; ?>

                //なぜかfoundが問題で動かなくなる。
                <?php //if(isset($found)):?>
                <?php //foreach($found as $v):?>
                //var maybes = [
                  //['<?php //echo $v->getID();?>//', <?php //echo $v->getLati();?>//, <?php //echo $v->getLongi();?>//],
                   //ex.['新宿', 35.688964547432306, 139.69959765672684]
                //];
                //alert(maybes);
               // マーカーを作成
                //jQuery.each(maybes, function()
                //{
                    //var latlng = new google.maps.LatLng(this[1], this[2]);
                    //var infoWindow = new google.maps.InfoWindow({
              	      //  content: ' こちらで<strong><?php //echo $v->getType();?>//</strong>が見つかりました！(<?php //echo $v->getHinichi();?>//)<br>特徴: <?php //echo $v->getColor(), ",", "(",$v->getSonota(), ")" ?>//<br><strong><?php //echo $v->getKeptin()?>//</strong>に届いてるかも！',
                    //});
                    //var marker = new google.maps.Marker({
                        //position: latlng,
                        //map: mapObj,
                        //title: this[0]
                   //});
                   // google.maps.event.addListener(marker, 'click', function() {
                	  //  infoWindow.open(map, marker);

                    //});
                 //});
                <?php //endforeach;?>
                <?php //endif;?>


                <?php if(isset($maybecolor)):?>
                <?php foreach($maybecolor as $v):?>
                var maybes = [
                  ['<?php echo $v->getID();?>', <?php echo $v->getLati();?>, <?php echo $v->getLongi();?>],
                   //ex.['新宿', 35.688964547432306, 139.69959765672684]
                ];
                //alert(maybes);
               // マーカーを作成
                jQuery.each(maybes, function()
                {
                    var latlng = new google.maps.LatLng(this[1], this[2]);
                    var infoWindow = new google.maps.InfoWindow({
              	        content: ' こちらで<strong><?php echo $v->getType();?></strong>が見つかりました！(<?php echo $v->getHinichi();?>)<br>特徴: <?php echo $v->getColor(), ",", "(",$v->getSonota(), ")" ?><br><strong><?php echo $v->getKeptin()?></strong>に届いてるかも！',
                    });
                    var marker = new google.maps.Marker({
                        position: latlng,
                        map: mapObj,
                        title: this[0]
                   });
                    google.maps.event.addListener(marker, 'click', function() {
                	    infoWindow.open(map, marker);

                    });
                 });
                <?php endforeach;?>
                <?php elseif(isset($maybetype)):?>
                <?php foreach($maybetype as $v):?>
                var maybes = [
                  ['<?php echo $v->getID();?>', <?php echo $v->getLati();?>, <?php echo $v->getLongi();?>],
                   //ex.['新宿', 35.688964547432306, 139.69959765672684]
                ];
                //alert(maybes);
               // マーカーを作成
                jQuery.each(maybes, function()
                {
                    var latlng = new google.maps.LatLng(this[1], this[2]);
                    var infoWindow = new google.maps.InfoWindow({
              	        content: ' こちらで<strong><?php echo $v->getType();?></strong>が見つかりました！(<?php echo $v->getHinichi();?>)<br>特徴: <?php echo $v->getColor(), ",", "(",$v->getSonota(), ")" ?><br><strong><?php echo $v->getKeptin()?></strong>に届いてるかも！',
                    });
                    var marker = new google.maps.Marker({
                        position: latlng,
                        map: mapObj,
                        title: this[0]
                   });
                    google.maps.event.addListener(marker, 'click', function() {
                	    infoWindow.open(map, marker);

                    });
                 });
                <?php endforeach;?>
                <?php else:?>
                <?php endif;?>


             } else {
                  alert('エラーです！');
             };
           })

         });






</script>

</div>
</div>

<div class="clr"></div>

<div id="contentLeft" >
<div id="koumoku">
<!-- <h2>2. 落し物を検索する</h2> -->

<!-- ここにその探したい物・色・場所を検索するのを入れる。その中でさらに絞り込むために日にち検索↓ -->
<?php echo form_tag("@find", "method=post multipart=true")?>

<table cellspacing="0" cellpadding="1" border="0">
<tr>
<td><h2><font color="#fff">2.　落し物を検索する：</font></h2></td><td><?php echo input_tag("hidmaybetype", $search_arr["hidmaybetype"], array("size => 20")) //input_tag("type", "", array("size => 20")) ?> </td>
<td>
<?php echo (isset($search_place))?input_hidden_tag("search_place", $search_place):""; ?>
<?php //echo (isset($found))?input_hidden_tag("found", $found):""; ?>
<?php //echo input_hidden_tag("hidmaybetype", $search_arr["hidmaybetype"]);?>
<?php echo (isset($hidmaybecolor))?input_hidden_tag("hidmaybecolor", $hidmaybecolor):"";?>
<?php echo submit_tag("OK")?><?php //echo reset_tag("リセット")?>
</td>
</tr>
</table>

</form>

</div>


<?php //var_dump($hidmaybetype)?>
<br>

<div id="resultlist">
<?php //var_dump($maybetype)?>
<?php if(isset($maybetype)):?>
検索結果<br><br>
<?php $num = 1;?>
<?php foreach($maybetype as $v):?>
<?php echo $num."　";?>
<?php echo "[ID:".$v->getId()."]　";?>
<?php //echo "ID".$v->getID();?>
<?php //echo $v->getCategory();?>
<?php $c_number = $v->getCategory();
      echo "[カテゴリ] ".$item_categorys[$c_number];?>
<?php echo "　[落とし物] ".$v->getType();?>
<?php echo "　[色] :".$v->getColor();?>
<?php //echo "　その他:".$v->getSonota();?>
<?php //echo $v->getLongi();?>
<?php //echo $v->getLati();?>
<?php $num++;?>
<?php echo "<br>"?>
<?php endforeach;?>
<?php endif;?>
</div>
</div>


<div id="contentRight">
<div id="koumoku"><h2>3.　絞込み検索をする</h2></div>
<div id="koumoku2">
<?php echo form_tag("@find", "method=post multipart=true")?>
<table cellspacing="0" cellpadding="1" border="0">
<tr>
<th>　色：</th><td><?php echo input_tag("hidmaybecolor", $search_arr["hidmaybecolor"], array("size=> 20")) //input_tag("color", "", array("size=> 20"))?> 例：黒　<br></td>
<td>
<?php echo (isset($search_place))?input_hidden_tag("search_place", $search_place):""; ?>
<?php //echo (isset($found))?input_hidden_tag("found", $found):""; ?>
<?php //echo input_hidden_tag("hidmaybecolor", $search_arr["hidmaybecolor"]);?>
<?php echo (isset($hidmaybetype))?input_hidden_tag("hidmaybetype", $hidmaybetype):"";?>
<?php echo submit_tag("OK")?><?php //echo reset_tag("リセット")?>
</td>
</tr>
</table>
</form>


<?php echo form_tag("@find",  array("name"=>"form1", "id"=>"form1", "method"=>"get", "multipart"=>true)) ?>
<table cellspacing="0" cellpadding="1" border="0">
<tr>
<th>　日付:</th>
<td>
<?php echo select_tag("year", options_for_select($year, $search_arr["year"], array("include_blank" => true)), array("onChange" => "changedate()"))
//echo select_tag("year", options_for_select(array("2008"=>"2008", "2009"=>"2009", "2010"=>"2010", "2011"=>"2011", "2012"=>"2012")), array("onChange" => "changedate()"))
?>年
<?php echo select_tag("month", options_for_select($month, $search_arr["month"], array("include_blank" => true)), array("onChange" => "changedate()"))
//echo select_tag("month", options_for_select(array("1"=>"1", "2"=>"2", "3"=>"3", "4"=>"4", "5"=>"5", "6"=>"6", "7"=>"7", "8"=>"8", "9"=>"9", "10"=>"10", "11"=>"11", "12"=>"12")), array("onChange" => "changedate"))?>月
<?php echo select_tag("days", options_for_select($days, $search_arr["days"], array("include_blank" => true)))
//echo select_tag("days", options_for_select(array("1"=>"1", "2"=>"2", "3"=>"3", "4"=>"4", "5"=>"5", "6"=>"6", "7"=>"7", "8"=>"8", "9"=>"9", "10"=>"10",
//"11"=>"11", "12"=>"12", "13"=>"13", "14"=>"14", "15"=>"15", "16"=>"16", "17"=>"17", "18"=>"18", "19"=>"19", "20"=>"20",
//"21"=>"21", "22"=>"22", "23"=>"23", "24"=>"24", "25"=>"25", "26"=>"26", "27"=>"27", "28"=>"28", "29"=>"29", "30"=>"30", "31"=>"31")))?>日	<br>
</td>
<td>
から　
<?php echo (isset($search_place))?input_hidden_tag("search_place", $search_place):""; ?>
<?php echo (isset($hidmaybetype))?input_hidden_tag("hidmaybetype", $hidmaybetype):""; ?>
<?php echo (isset($hidmaybecolor))?input_hidden_tag("hidmaybecolor", $hidmaybecolor):""; ?>
<?php echo submit_tag("OK" )?><?php //echo reset_tag("リセット")?>
</td>
</tr>
</table>
</form>
</div>


<!-- 上の情報をＧＥＴしてＤＢに聞きにいって、そのリストが下に出る。同時にgooglemapsに反映。 -->
<br>

<div id="resultlist2">
<?php //var_dump($maybecolor)?>
<?php if(isset($maybecolor)):?>
絞込み結果<br><br>
<?php $num = 1;?>
<?php foreach($maybecolor as $v):?>
<?php echo $num."　";?>
<?php echo "[ID:".$v->getId()."] ";?>
<?php //$c_number = $v->getCategory();
      //echo "[カテゴリ] ".$item_categorys[$c_number];?>
<?php echo "　[落とし物] ".$v->getType();?>
<?php //echo "　その他：".$v->getSonota();?>
<?php echo "　[色] ".$v->getColor();?>
<?php echo "　[日付] ".$v->getHinichi();?>
<?php echo "<br>";?>
<?php $num++;?>
<?php endforeach;?>
<?php endif;?>
</div>



<?php echo form_tag("@find", "method=post multipart=true")?>
<?php echo input_hidden_tag("reset_all", "y");?>
<?php //echo input_hidden_tag("search_place", ""); ?>
<?php //echo input_hidden_tag("hinichi", ""); ?>
<?php //echo input_hidden_tag("maybetype", "");?>
<?php //echo input_hidden_tag("maybecolor", "");?>
<?php //echo input_hidden_tag("hidmaybetype", ""); ?>
<?php //echo input_hidden_tag("hidmaybecolor", ""); ?>
<?php echo submit_tag("全てリセット");?>
</form>
<?php //print_r($search_place);?>
<?php //print_r($hinichi);?>
<?php //print_r($hidmaybetype);?>
<?php //print_r($hidmaybecolor);?>
<?php //print_r($maybetype);?>
<?php //print_r($maybecolor);?>
現在<font color="red"><?php echo $cnt;?>件</font>の落し物情報が登録されています。



</div>
